package br.com.itc;

/**
 *
 * @author Ricardo Levindo
 * 
 * */

public class Fita {

	char[] tape;
	int position = -1;

	public Fita(String s) {
		tape = new char[s.length()];

		for (int i = 0; i < s.length(); i++)
			tape[i] = s.charAt(i);
	}

	public char read() {
		if (!(this.position < length()) || this.position == -1) {
			this.position++;
			return '$';
		} else if (this.position == length())
			return '$';
		else 
			return tape[this.position++];
	}

	public int length() {
		return tape.length;
	}

	public String toString() {

		String s = "";

		for (char t : tape)
			s = s + "|" + t;

		s = s + "|";

		return s;
	}
}